package com.xwdeshj.controller;

import com.alibaba.fastjson.JSONObject;
import com.xwdeshj.service.XwScenicBasicinfoService;
import com.xwdeshj.utils.IMoocExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by BKWJA on 2018/12/24.
 * 景区店铺基本信息控制层
 */
@Slf4j
@RequestMapping("scebusinesinfo")
@CrossOrigin(allowCredentials = "true")
@Controller
public class XwScenicBasicinfoController extends IMoocExceptionHandler {

    @Autowired
    private XwScenicBasicinfoService xwScenicBasicinfoService;


    /**
     * 农家乐信息查询
     * @param pagesize  每页显示多少条记录
     * @param pageindex  当前页
     * @param starttime 开始时间
     * @param endtime  结束时间
     * @param searchval   查询关键字
     * @param searchkey  查询字段名
     * @param sortfild  排序字段
     * @param sortway  排序（升序，降序）
     * @param type  景区类型
     * @param grade  景区等级
     * @return
     */
    @RequestMapping("/gettourinfolist")
    @ResponseBody
    public JSONObject gettourinfolist(@RequestParam(value = "pagesize",defaultValue = "10") Integer pagesize,
                                      @RequestParam(value = "pageindex",defaultValue = "1") Integer pageindex,
                                      @RequestParam(value = "starttime",defaultValue = "") String starttime,
                                      @RequestParam(value = "endtime",defaultValue = "") String endtime,
                                      @RequestParam(value = "searchval",defaultValue = "") String searchval,
                                      @RequestParam(value = "searchkey",defaultValue = "") String searchkey,
                                      @RequestParam(value = "sortfild",defaultValue = "scenic_createtime") String sortfild,
                                      @RequestParam(value = "sortway",defaultValue = "desc")String sortway,
                                      @RequestParam(value = "type",defaultValue = "")String type,
                                      @RequestParam(value = "grade",defaultValue = "")String grade,
                                      HttpServletRequest request){
        searchval.trim();
        return xwScenicBasicinfoService.gettourinfolist(pagesize,pageindex,starttime,endtime,searchval,searchkey,
                sortfild,sortway,type,grade,request);
    }


    /**
     *  景区——商家详情——获取 景区基本信息（一条）
     * @param business_encryptId 商家加密id
     * @param sceinc_encryptId 店铺加密id
     * @param request
     * @return
     */
    @RequestMapping("/getfarminfoOne")
    @ResponseBody
    public JSONObject getfarminfoOne(@RequestParam(value = "business_encryptId",defaultValue = "")
                                                 String business_encryptId,
                                  @RequestParam(value = "sceinc_encryptId",defaultValue = "")
                                          String sceinc_encryptId,
                                  HttpServletRequest request){
        return xwScenicBasicinfoService.getfarminfoOne(business_encryptId,sceinc_encryptId,request);
    }

    /**
     *  景区——修改商家的游玩类型备注
     * @param sceinc_encryptId 店铺加密id
     * @param themeRemarks  主题游备注
     * @param theme_encryptId  主题游加密
     * @param play_encryptId  游玩类型加密id
     * @param playRemarks  游玩类型备注
     * @param crowdRemarks  适合人群备注
     * @param crowd_encryptId  适合人群加密id
     * @param request
     * @return
     */
    @RequestMapping("/modifysceincRemarks")
    @ResponseBody
    public JSONObject modifysceincRemarks(@RequestParam(value = "sceinc_encryptId",defaultValue = "")
                                                          String sceinc_encryptId, String themeRemarks,
                                              String theme_encryptId,String playRemarks,String play_encryptId,
                                              String crowdRemarks,String crowd_encryptId,HttpServletRequest request){
        return xwScenicBasicinfoService.modifysceincRemarks(sceinc_encryptId,themeRemarks,
                theme_encryptId,playRemarks,play_encryptId,crowdRemarks,crowd_encryptId,request);
    }

    /**
     * 景区——修改商家基本信息
     * @param business_encryptId 商家加密id
     * @param scenic_encryptId 店铺加密id
     * @param updatefiled 修改的字段名
     * @param updateval 修改的内容
     * @param request
     * @return
     */
    @RequestMapping("/updateSceincinfo")
    @ResponseBody
    public JSONObject updateSceincinfo(@RequestParam(value = "business_encryptId",defaultValue = "")String business_encryptId,
                                     @RequestParam(value = "scenic_encryptId",defaultValue = "")String scenic_encryptId,
                                     String updatefiled,String updateval,HttpServletRequest request){
        updateval = updateval.trim();
        return xwScenicBasicinfoService.updateSceincinfo(business_encryptId,scenic_encryptId,updatefiled,updateval,request);
    }




}
